Using the Instantiator node

Use the Instantiator node to replicate the appearance of a 3D node or a tree of 3D nodes the Instantiator node targets. Instantiator node contains a reference to a target node or a tree of nodes. When Kanzi renders the Instantiator node it copies the appearance of the object the Instantiator node targets. This means that all changes to the target node are always reflected in the Instantiator node. For example, you can use the Instantiator node to create a reflection. See Tutorial: Create reflections.

Each Instantiator node has a unique transformation, so you can use more than one Instantiator node to target the same object. You cannot override other properties in the Instantiator node, so all instances are identical. However, each Instantiator node is rendered separately. For example, this enables lights to differently affect Instantiator nodes in different positions.

To create truly unique instances of a node, convert that node to a prefab, and use instances of that prefab. See Using prefabs.

Note that Instantiator node affects only rendering. Because the layout size of an Instantiator node is 0 you cannot use it in layouts. The instantiated nodes are not interactive.

Creating an Instantiator node

To create an Instantiator node:

  1. In the Project press Alt and right-click the node where you want to create an Instantiator node and select Instantiator.
    Note that you can create the Instantiator node only inside 3D nodes.
  2. In the Properties set the Instantiated Node property to the node you want to replicate with this Instantiator node.
    Kanzi Studio instantiates the node.
  3. (Optional) In the Properties add and set properties to change the instantiated node.
    For example, set the Render Transformation or Ambient Color property.

Creating an Instantiator node from a node

To create an Instantiator node from a node:

  1. In the Project press Alt and right-click the node you want the Instantiator node to show and select Instantiate Into an Instantiator.
    Kanzi Studio creates an Instantiator node and sets its Instantiated Node property to the selected node.
  2. (Optional) In the Properties add and set properties to change the instantiated node.
    For example, set the Render Transformation or Ambient Color property.

Using the Instantiator node in the API

To create a reflection using an instantiator node.

// Create an instantiator node named Instantiator3D.
Instantiator3DSharedPtr instantiator = Instantiator3D::create(domain, "Instantiator3D");
// Set the target object which the instantiator node is going to reflect.
instantiator->setTarget(targetNode);
// Set non-uniform scaling of the instantiator node to mirror the target object
// across the xz plane. Note that this inverts all triangles so you have
// to disable the backface culling rendering for the instantiator.
instantiator->setRenderTransformation(SRTValue3D::createScale(Vector3(1.0f, -1.0f, 1.0f)));

For details, see the Instantiator3D class in the API reference.

Instantiator node property types and messages

For a list of the available property types and messages for the Instantiator node, see Instantiator.

See also

Tutorial: Create reflections